package com.example.frn.dao;

import com.example.frn.entity.Category;
import com.example.frn.entity.Film;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.util.List;

@Mapper
@Repository
public interface CategoryMapper {
    @Insert("insert into category(name) value(#{name})" )
    int insert(Category category);
    //执行逻辑删除，更新对应记录的is_delete字段
    @Update("update category set is_delete=1 where ID=#{param}")
    int deleteById(Integer id);
    @Update("update category set name = #{name} where ID=#{id}")
    int updateById(Category category);
    @Select("select * from category where ID=#{param} and is_delete = 0")
    Category selectById(Integer id);
    @Select("select * from category where is_delete = 0")
    List<Category> List();
    @Select("select * from film_category where is_delete = 0 and category_id = #{id} ")
    List<Film> listForFilm(Integer id);
}
